package com.kelvem.saas.workbanch.security.shiro;

import com.kelvem.saas.workbanch.core.system.model.SysUserEntity;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.shiro.SecurityUtils;

/**
 * 从Shiro中获取
 */
public class CurrentUser {

    public static void set(SysUserEntity user) {
        throw new NotImplementedException();
    }

    public static SysUserEntity get() {
        return (SysUserEntity)SecurityUtils.getSubject().getPrincipal();
    }

    public static void remove() {
        throw new NotImplementedException();
    }

    private CurrentUser() {
        // do nothing
    }

//    private static final ThreadLocal<SysUserEntity> loginUser = new ThreadLocal<>();
//
//    public static void set(SysUserEntity user) {
//        loginUser.set(user);
//    }
//
//    public static SysUserEntity get() {
//        return loginUser.get();
//    }
//
//    public static void remove() {
//        loginUser.remove();
//    }
}
